import api from "../../api/api.js"
import consts from "../../utils/consts.js"

var app = getApp();
Page({
  data: {
    userInfo: null
  },
  onShow: function (options) {
    this.setData({
      userInfo: app.globalData.userInfo
    })
  },
  bindUserInfoTap: function (e) {
    var that = this
    api.reg({
      method:'get',
      data:{
        openid: app.globalData.openid,
        nickName: e.detail.userInfo.nickName,
        avatarUrl: e.detail.userInfo.avatarUrl,
        gender: e.detail.userInfo.gender,
        country: e.detail.userInfo.country,
        provice: e.detail.userInfo.provice,
        city: e.detail.userInfo.city,
        language: e.detail.userInfo.language
      },
      success:function(resp){
        if (resp.code== 0){
          app.globalData.openid = resp.data.user.openid
          app.globalData.userInfo = resp.data.user
          app.globalData.userConf = resp.data.conf
          that.setData({
            userInfo: app.globalData.userInfo
          })
        }
      }
    })
  }
})